package com.presto.directo.utils

import android.app.Activity
import android.app.Dialog
import android.view.Gravity
import androidx.annotation.FloatRange
import com.presto.directo.R


fun Activity.showDialog(@FloatRange(from = 0.0, to = 1.0) width: Float = 0.9f, gravity: Int = Gravity.CENTER, display: (dialog: Dialog) -> Unit) {
    val dialog = Dialog(this, R.style.BaseDialog)
    dialog.setCancelable(false)
    display(dialog)
    dialog.window?.attributes?.width = (getScreenWidth() * width).toInt()
    dialog.window?.attributes?.gravity = gravity
    dialog.show()
}